home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AOL File Library: 2,801 to 2,900
/
aol-file-protocol-4400-2801-to-2900.zip
/
AOLDLs
/
C++ Files Library
/
Acere (Card Game)
/
AcereÄ.sit
/
Acereƒ
/
AcereApp.cp
< prev
next >
Wrap
Text File
|
1994-08-25
|
6KB
|
229 lines
// ===========================================================================
// AcereApp.cp ⌐1994 Metrowerks Inc. All rights reserved.
// ===========================================================================
//
// A simple Application class which manages text documents.
#include "AcereApp.h"
#include "CTextDoc.h"
#include "CardWell.h"
#include "CardDeck.h"
#include "WellDeck.h"
#include "WellFreeCell.h"
#include "WellStack.h"
#include <LApplication.h>
#include <LGrowZone.h>
#include <LWindow.h>
#include <LScroller.h>
#include <LPrintout.h>
#include <LPlaceHolder.h>
#include <UMemoryMgr.h>
#include <UDrawingState.h>
#include <UPowerTools.h>
#include <URegistrar.h>
#include <UDesktop.h>
AcereApp *theApp;
extern CTextDoc *theDoc;
// ===========================================================================
// Ñ Main Program
// ===========================================================================
void main(void)
{
// Set Debugging options
#ifdef Debug_Throw
gDebugThrow = debugAction_Alert;
#endif
#ifdef Debug_Signal
gDebugSignal = debugAction_Alert;
#endif
InitializeHeap(3); // Initialize Memory Manager
// Parameter is number of Master Pointer
// blocks to allocate
// Initialize standard Toolbox managers
UQDGlobals::InitializeToolbox(&qd);
#ifdef Debug_Signal // Check for missing MBAR, which
CheckForInitialMBAR(); // probably means that there is no
#endif // project resource file
new LGrowZone(20000); // Install a GrowZone function to catch
// low memory situations.
// Parameter is size of reserve memory
// block to allocated. The first time
// the GrowZone function is called,
// there will be at least this much
// memory left (so you'll have enough
// memory to alert the user or finish
// what you are doing).
theApp = new AcereApp; // Create instance of your Application
theApp->Run(); // class and run it
}
// ===========================================================================
// Ñ AcereApp Class
// ===========================================================================
// ---------------------------------------------------------------------------
// Ñ AcereApp
// ---------------------------------------------------------------------------
// Constructor
AcereApp::AcereApp()
{
short i;
theDoc = nil;
for (i=0; i<4; i++) // load up the patterns
{
suitPats[i][0] = GetCIcon(1000+i);
suitPats[i][1] = GetCIcon(1100+i);
}
// Register classes for objects created from 'PPob' resources
URegistrar::RegisterClass('wind', (ClassCreatorFunc) LWindow::CreateWindowStream);
URegistrar::RegisterClass('scrl', (ClassCreatorFunc) LScroller::CreateScrollerStream);
// URegistrar::RegisterClass('Dtxt', (ClassCreatorFunc) CDirtyText::CreateDirtyTextStream);
URegistrar::RegisterClass('plac', (ClassCreatorFunc) LPlaceHolder::CreatePlaceHolderStream);
URegistrar::RegisterClass('prto', (ClassCreatorFunc) LPrintout::CreatePrintoutStream);
URegistrar::RegisterClass('view', (ClassCreatorFunc) CardWell::CreateCardWell);
URegistrar::RegisterClass('CWwl', (ClassCreatorFunc) WellFreeCell::CreateWellFreeCell);
URegistrar::RegisterClass('CWdk', (ClassCreatorFunc) WellStack::CreateWellStack);
URegistrar::RegisterClass('CWst', (ClassCreatorFunc) WellDeck::CreateWellDeck);
// ourDoc = (CTextDoc *)MakeNewDocument();
}
// ---------------------------------------------------------------------------
// Ñ ~AcereApp
// ---------------------------------------------------------------------------
// Destructor
AcereApp::~AcereApp()
{
// +++ Add code here to cleanup (if necessary) before quitting
}
// ---------------------------------------------------------------------------
// Ñ ObeyCommand
// ---------------------------------------------------------------------------
// Respond to commands
Boolean
AcereApp::ObeyCommand(
CommandT inCommand,
void *ioParam)
{
Boolean cmdHandled = true;
switch (inCommand) {
// +++ Add cases here for the commands you handle
// Remember to add same cases to FindCommandStatus below
// to enable/disable the menu items for the commands
default:
cmdHandled = LDocApplication::ObeyCommand(inCommand, ioParam);
break;
}
return cmdHandled;
}
// ---------------------------------------------------------------------------
// Ñ FindCommandStatus
// ---------------------------------------------------------------------------
// Pass back status of a (menu) command
void
AcereApp::FindCommandStatus(
CommandT inCommand,
Boolean &outEnabled,
Boolean &outUsesMark,
Char16 &outMark,
Str255 outName)
{
outUsesMark = false;
switch (inCommand) {
// +++ Add cases here for the commands you handle
default:
LDocApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
outMark, outName);
break;
}
}
// ---------------------------------------------------------------------------
// Ñ OpenDocument
// ---------------------------------------------------------------------------
// Open a Document file
void
AcereApp::OpenDocument(
FSSpec *inMacFSSpec)
{
theDoc = new CTextDoc(this, inMacFSSpec);
}
// ---------------------------------------------------------------------------
// Ñ MakeNewDocument
// ---------------------------------------------------------------------------
// Create a new Document
LModelObject*
AcereApp::MakeNewDocument()
{
if (theDoc == nil)
{
theDoc = new CTextDoc(this, nil);
}
else
{
theDoc->StartNewGame();
}
return theDoc;
}
// ---------------------------------------------------------------------------
// Ñ ChooseDocument
// ---------------------------------------------------------------------------
// Prompt the user to select a document to open
void
AcereApp::ChooseDocument()
{
StandardFileReply macFileReply;
SFTypeList typeList;
UDesktop::Deactivate();
typeList[0] = 'TEXT';
::StandardGetFile(nil, 1, typeList, &macFileReply);
UDesktop::Activate();
if (macFileReply.sfGood) {
OpenDocument(&macFileReply.sfFile);
}
}